#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <pthread.h>

void* pthread_running(void *_val)
{
    pthread_detach(pthread_self());
    printf("%s\n", (char*)_val);
    return NULL;
}

int main()
{
    pthread_t tid;
    int ret = pthread_create(&tid, NULL, pthread_running, "main thread is running");
    int temp = 0;
    sleep(1);
    if(0 == pthread_join(tid, NULL))
    {
        printf("pthread wait success!\n");
    }
    else
    {
        // 父进程企图使用pthread_join等待子进程退出，然而失败了
        printf("pthread wait failed!\n");
    }
    return temp;
}
